<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <title>Register</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/signin.css" rel="stylesheet">

</head>

<body>
<!-- page header start-->
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index">主页</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <%
                    String user = (String) request.getSession().getAttribute("user");
                    if (user == null || user.equals("")) {
                %>
                <li><a href="login.jsp">登录</a></li>
                <li><a href="register.jsp">注册</a></li>
                <%
                } else {
                %>
                <li><a href=""><%=request.getSession().getAttribute("user")%>
                </a></li>
                <li><a href="edit.jsp">发新闻稿</a></li>
                <%
                    if ((boolean) request.getSession().getAttribute("manager")) {
                %>
                <li><a href="manager.jsp">管理</a></li>
                <%
                    }
                %>
                <li><a href="logout">退出</a></li>
                <%
                    }
                %>
            </ul>
        </div><!--/.nav-collapse -->
    </div>
</nav>
<!-- page header end-->


<div class="container">

    <form class="form-signin" action="register" method="post">
        <h2 class="form-signin-heading">注册新用户</h2>

        <label for="inputUsername" class="sr-only">UserName</label>
        <input type="text" name="user" id="inputUsername" class="form-control" placeholder="用户名，只能包含字母、数字和下划线" required
               autofocus pattern="[a-zA-Z0-9_]{0,}">

        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" name="password" id="inputPassword" class="form-control" placeholder="密码" required>

        <label for="inputPasswordAgain" class="sr-only">Password</label>
        <input type="password" name="again" id="inputPasswordAgain" class="form-control" placeholder="再次输入" required>

        <label for="inputCode" class="sr-only">COde</label>
        <input type="text" name="code" id="inputCode" class="form-control" placeholder="注册码" required
               autofocus>

        <button class="btn btn-lg btn-primary btn-block" type="submit">注册</button>
        <span><a href="login.jsp">登录</a></span>
    </form>

</div> <!-- /container -->

<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
